; each routine begins with the declaration <ROUTINE and then the name of that routine
; then each entry for that routine must begin with an open bracket 
; an entry can call another routine
; a condition must begin with an IF - allowable IF condition checks:
; (IF
;
; test items below are boolean options - these are all yes / no conditions:
; IF VERB=... if player has typed the verb... (must be followed by a verb to check)
;
; IF ROOM.PLAYER=... if the room that the player is currently in is... (must be followed by a ROOM)
; IF ROOM.THIS=... if the room that the object the player typed in is currently in is... (must be followed by a ROOM or PLAYER)
; IF ROOM.anyOBJECT=... if the room that the object specified is in is... (must be followed by a ROOM, could be PLAYER if it's carried)
;
; if an object has a room value of NONE, this means it doesn't physically exist in the game, can't be picked up, carried etc
; but the parser will process it. For example - xyzzy or north
; for example, "switch light on" - this has a verb ("switch") and two objects "light" is the main OBJECT, and "on" is the INDIRECT object.
; for example, "tie rope to pole" - the verb is "tie", OBJECT is "rope" and "pole" is INDIRECT object
; In routines that deal with two objects, .THIS references the main object, 
; and .INDIRECT references the indirect object.

; EXAMPLES OF CONDITIONS:
; IF FLAGSET.THIS=XYZ if the object or room typed in by the player has the XYZ flag set (XYZ must be a valid FLAG)
; IF FLAGSET.anyOBJ/ROOM=XYZ if the object or room specified has the XYZ flag set  (XYZ must be a valid FLAG)
;
; IF FLAGUNSET.THIS=XYZ if the object or room typed in by the player does not have the XYZ flag set  (XYZ must be a valid FLAG)
; IF FLAGUNSET.anyOBJ/ROOM=XYZ if the object or room specified does not have the XYZ flag set  (XYZ must be a valid FLAG)
;
; IF EXCEEDCARRY : (no = needed) if the SIZE of the object typed in PLUS the current carried SIZE is greater than player's max carry

; there can be more than one condition on each IF - each condition must be separated by an AND or an OR
; following all the conditions, there must be a concluding THEN 
; and then the list of assignments to be carried out if all the conditions of that IF are successful.
     
; EXAMPLES OF ASSIGNMENTS:
; SETFLAG.THIS XYZ - sets specified flag for the object typed in - XYZ must be a valid FLAG
; SETFLAG.anyOBJ/ROOM XYZ - sets specified flag for a specified object or room - XYZ must be a valid FLAG
;
; UNSETFLAG.THIS XYZ - unsets specified flag for the object typed in by player - XYZ must be a valid FLAG
; UNSETFLAG.TRAPDOOR XYZ - unsets specified flag for a specified object - XYZ must be a valid FLAG
;
; SETROOM.THIS ROOMXYZ - sets the location of the object typed in - ROOMXYZ must be a valid ROOM or PLAYER
; SETROOM.anyOBJ ROOMXYZ - sets the location of a specified OBJECT (mustn't be a door object) - ROOMXYZ must be a valid ROOM or PLAYER
;
; SETSIZE.THIS - sets the size value of the object typed in by player - must be followed by a numerical value
; SETSIZE.LAMP - sets the size value of a specified object - must be followed by a numerical value
;
; ~not implemented yet: MAXCARRY - sets the maximum amount the player can carry - must be followed by a numerical value)
; ~not implemented yet: INC.CARRIED 000 - increases the amount the player is carrying - must be followed by a numerical value 
; INC.CARRIED SIZE.THIS - increases the amount the player is carrying by the SIZE of the object typed in
; ~not implemented yet: DEC.CARRIED 000 - decreases the amount the player is carrying - must be followed by a numerical value
; DEC.CARRIED SIZE.THIS - decreases the amount the player is carrying by the SIZE of the object typed in
; ~not implemented yet: INC.SCORE 000  - increases the score of the player - must be followed by a numerical value
; ~not implemented yet: DEC.SCORE 000
;
; TELL "Words words words." (puts the words up on screen) - 
; in TELL, you can put % between the quotes and 
; the parser will replace it with the object that the player has typed in    
; there can be more than one assignment after the THEN,
; the last assignment must be terminated by a close bracket )
; then the next condition must begin again with an open bracket
; the whole routine must be closed with a greater than sign >

; -----------------SAMPLE CODE STARTS HERE-------------------

<ROUTINE GET_ROUTINE
  (IF ROOM.THIS<>ROOM.PLAYER THEN
    TELL "I can't see any % here to pick up.")
  (IF SIZE.THIS=100 THEN
    TELL "There's no way I can pick that up!")
  (IF EXCEEDCARRY THEN
    TELL "You can't pick it up, you are encumbered. You could try dropping some other things first.")
  (SETROOM.THIS=PLAYER
    INC.CARRIED SIZE.THIS
    TELL "You pick up the %.")>

<ROUTINE DROP_ROUTINE
  (IF ROOM.THIS<>PLAYER THEN
    TELL "But you're not carrying the %.")
  (SETROOM.THIS=ROOM.PLAYER
    DEC.CARRIED SIZE.THIS
    TELL "You drop the %.")>

<ROUTINE INVENTORY_ROUTINE
  (TELL "You are currently carrying:"
    GETINV)>

<ROUTINE TRAPDOOR_ROUTINE
  (ROUTINE OPEN_CLOSE_ROUTINE)
  (IF VERB=LOCK AND ROOM.TRAPDOOR_KEY<>PLAYER THEN
     TELL "But you're not carrying the trapdoor key.")
  (IF VERB=LOCK AND FLAGSET.THIS=OPEN THEN
     UNSETFLAG.THIS OPEN
     SETFLAG.THIS LOCKED
     TELL "You lift the trapdoor closed, and twist the key in the lock. It clunks satisfyingly.")
  (IF VERB=LOCK THEN
     SETFLAG.THIS LOCKED
     TELL "You twist the key in the lock. It clunks satisfyingly.")

  (IF VERB=UNLOCK AND ROOM.TRAPDOOR_KEY<>PLAYER THEN
     TELL "But you're not carrying the trapdoor key.")
  (IF VERB=UNLOCK AND FLAGSET.THIS=OPEN THEN
     TELL "But it's already open.")
  (IF VERB=UNLOCK AND FLAGUNSET.THIS=LOCKED THEN
     TELL "But it's already unlocked.")
  (IF VERB=UNLOCK THEN
     TELL "You twist the key in the lock. It clunks satisfyingly.")>

<ROUTINE OPEN_CLOSE_ROUTINE
  (IF VERB=OPEN AND FLAGSET.THIS=LOCKED THEN
    TELL "It won't open - it must be locked.")
  (IF VERB=OPEN AND FLAGUNSET.THIS=OPEN THEN
    SETFLAG.THIS OPEN
    TELL "You open the %.")
  (IF VERB=OPEN THEN
    TELL "It is already open.")
  (IF VERB=CLOSE AND FLAGSET.THIS=OPEN THEN
    UNSETFLAG.THIS OPEN
    TELL "You close the %.")
  (IF VERB=CLOSE THEN
    TELL "The % is already closed.")>

<ROUTINE OPEN_ROUTINE
  (TELL "I don't know how to open a %.")>

<ROUTINE CLOSE_ROUTINE
  (TELL "I don't know how to close a %.")>


EOF!

; -----------END OF SAMPLE CODE--------------

; the EOF! must exist at the end of the file, with a carriage return (enter key)
; for the parser to recognise the end of the file

; flags recognised by the parser:
; INVISIBLE (an object cannot be seen, and will not be written up, even if it is in the room with the player

; special location values:
; if the location of an object is set to PLAYER, this denotes it is being carried
; if the location of an object is set to NONE, this denotes it does not exist in the world
; (eg, after a food item has been eaten, or for words like xyzzy or plugh!)


